package com.hushan.elevator.service.impl;

import com.hushan.elevator.dao.DeviceMntRepository;
import com.hushan.elevator.dao.DeviceMntPersonRepository;
import com.hushan.elevator.model.Department;
import com.hushan.elevator.model.DeviceMntPerson;
import com.hushan.elevator.service.DeviceMntPersonService;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeviceMntPersonServiceImpl implements DeviceMntPersonService {

    private final DeviceMntPersonRepository mntUserRepository;

    @Autowired
    public DeviceMntPersonServiceImpl(DeviceMntPersonRepository mntUserRepository) {
        this.mntUserRepository = mntUserRepository;
    }

    @Override
    public List<DeviceMntPerson> findAll() {
        return mntUserRepository.findAll();
    }

    @Override
    public DeviceMntPerson findById(Integer id) {
        return mntUserRepository.findById(id).orElse(null);

    }


    @Override
    public List<DeviceMntPerson> findByCreatedTimeBetween(LocalDateTime start, LocalDateTime end) {
        return mntUserRepository.findByCreatedTimeBetween(start, end);
    }

    @Override
    public List<DeviceMntPerson> findByUpdatedTimeBetween(LocalDateTime start, LocalDateTime end) {
        return mntUserRepository.findByUpdatedTimeBetween(start, end);

    }

    @Override
    public void save(DeviceMntPerson DeviceMntPerson) {
        mntUserRepository.save(DeviceMntPerson);

    }

    @Override
    public void delete(Integer id) {
        mntUserRepository.deleteById(id);

    }

    @Override
    public long findCountByDept(int id) {
        DeviceMntPerson example = new DeviceMntPerson();

        mntUserRepository.count();
        return 0;
    }

    @Override
    public void addDeviceMntPerson(DeviceMntPerson deviceMntPerson) {
        deviceMntPerson.setCreatedTime(LocalDateTime.now());
        deviceMntPerson.setUpdatedTime(LocalDateTime.now());
        mntUserRepository.save(deviceMntPerson);
    }
}
